<template>
    <div style="width: 100%;">
        <el-page-header @back="goBack" content="大型物资招标采购计划列表">
        </el-page-header>
        <el-divider></el-divider>
        <el-form :inline="true">
            <el-form-item>
                <el-input v-model="params.planId" placeholder="招标编号" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item>
                <el-input v-model="params.projectName" placeholder="项目名称" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item>
                <el-select v-model="params.approveStatus" :value="params.approveStatus">
                    <el-option label="审批状态" value=""></el-option>
                    <el-option label="审批中" value="1"></el-option>
                    <el-option label="审批不通过" value="2"></el-option>
                    <el-option label="审批通过" value="3"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-select v-model="params.status" :value="params.status">
                    <el-option label="招标状态" value=""></el-option>
                    <el-option label="待招标" value="1"></el-option>
                    <el-option label="招标进行中" value="2"></el-option>
                    <el-option label="中标" value="3"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-input v-model="params.planEditor" placeholder="编制人" :clearable="true"></el-input>
            </el-form-item>
            <el-form-item style="margin-left: 10px">
                <el-button @click="handleSearch" type="primary">检索</el-button>
            </el-form-item>
        </el-form>

        <el-table :data="pageResult.records">
            <el-table-column label="序号" type="index"></el-table-column>
            <el-table-column label="招标编号" prop="id"></el-table-column>
            <el-table-column label="项目名称" prop="projectName"></el-table-column>
            <el-table-column label="编制人" prop="planEditor"></el-table-column>
            <el-table-column label="日期" prop="date"></el-table-column>
            <el-table-column label="流程状态" prop="approveStatus">
                <template slot-scope="scope">
                    <span style="color: orange;font-weight: 700" v-if="scope.row.approveStatus=='1'">审批中</span>
                    <span style="color: red;font-weight: 700" v-if="scope.row.approveStatus=='2'">审批不通过</span>
                    <span style="color: green;font-weight: 700" v-if="scope.row.approveStatus=='3'">审批通过</span>
                </template>
            </el-table-column>
            <el-table-column label="状态">
                <template slot-scope="scope">
                    <span style="color: #8c939d;font-weight: 700" v-if="scope.row.status=='1'">待招标</span>
                    <span style="color: #20a0ff;font-weight: 700" v-if="scope.row.status=='2'">招标进行中</span>
                    <span style="color: green;font-weight: 700" v-if="scope.row.status=='3'">中标</span>
                </template>
            </el-table-column>
            <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-dropdown @command="handleCommand" trigger="click">
                        <el-button>
                            操作<i class="el-icon-arrow-down el-icon--right"></i>
                        </el-button>
                        <el-dropdown-menu slot="dropdown">
                            <el-dropdown-item :command="{row:scope.row,type:'remove'}" v-if="scope.row.approveStatus=='2'">删除</el-dropdown-item>
                            <el-dropdown-item :command="{row:scope.row,type:'project'}">项目详情</el-dropdown-item>
                            <el-dropdown-item :command="{row:scope.row,type:'details'}">分包招标详情</el-dropdown-item>
                        </el-dropdown-menu>
                    </el-dropdown>
                </template>
            </el-table-column>
        </el-table>
        <el-divider></el-divider>

        <el-footer class="case-list-footer">
            <el-pagination
                    style="margin: 10px auto"
                    background
                    layout="total , sizes ,prev, pager, next,jumper"
                    :page-sizes="[5,10,15,20]"
                    :total="pageResult.total"
                    :page-size="pageResult.size"
                    class="pagination"
                    @current-change="handleIndexChange"
                    @size-change="handleSizeChange"
            >
            </el-pagination>
        </el-footer>
    </div>
</template>

<script>
    import {SubTenderPlanService} from "../../../model/gs/SubTenderPlanService";

    const subTenderPlanService = SubTenderPlanService.getInstance()

    export default {
        data() {
            return {
                params: {
                    planId: '',
                    projectName: '',
                    approveStatus: '',
                    planEditor:'',
                    status:''
                },
                projectTypeList:[],
                pageResult:[]
            }
        },
        methods:{
            getSubTenderPlanList(){
                subTenderPlanService.getPageList(this.params).then(response => {
                    if(response.data.code === 0){
                        this.pageResult = response.data.data
                    }
                })
            },
            handleSearch(){
                this.params.page = 1
                this.getSubTenderPlanList()
            },
            handleIndexChange(index){
                this.params.page = index
                this.getSubTenderPlanList()
            },
            handleSizeChange(size){
                this.params.size = size
                this.getSubTenderPlanList()
            },
            handleCommand(command){
                switch (command.type) {
                    case 'details': this.handleSHowDetails(command.row);break;
                }
            },
            handleSHowDetails(row){
                this.$router.push({
                    name:'SubPlanEdit',
                    params:{
                        row
                    }
                })
            },
            goBack(){
                history.back()
            }
        },
        created(){
            this.getSubTenderPlanList()
        }
    }
</script>

<style scoped>

</style>
